home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 1902 < prev    next >
Encoding:
Text File  |  1996-08-05  |  1.3 KB  |  50 lines

  1. Path: atglab.bls.com!Alun.Champion
  2. From: Alun.Champion@bridge.bst.bls.com (Alun Champion)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: Secure from Decompiling??
  5. Date: 17 Jan 1996 18:51:06 GMT
  6. Organization: Computer People Inc.
  7. Message-ID: <ALUN.CHAMPION.96Jan17135106@g7240065.bridge.bst.bls.com>
  8. References: <4djaq2$jd5@earth.superlink.net>
  9. NNTP-Posting-Host: bstfirewall.bst.bls.com
  10. In-reply-to: rstewart@mars.superlink.net's message of Wed, 17 Jan 1996
  11.     17:14:17 GMT
  12.  
  13. In article <4djaq2$jd5@earth.superlink.net> rstewart@mars.superlink.net (Bob Stewart) writes:
  14.  
  15. :  I have a compiled C program containing a string that I want no one to
  16. : be able to see, even with a decompiler. 
  17.  
  18. : Is there any thing to put in the code that can prevent it from being
  19. : decompiled, or make the decompiled code unintelligle??
  20.  
  21. : Thanks for your help,
  22.  
  23. A simple mechanism is to only initialise the string to an encrypted form
  24. and then decrypt at runtime.
  25.  
  26. Example:
  27.  
  28. #include <stdio.h>
  29.  
  30. int
  31. main(void)
  32. {
  33.     char a[] = "\xad\x80\x89\x89\x8a\xc5\x92\x8a\x97\x89\x81\xc4\xc4\xef";
  34.     
  35.     for (char* p = a; *p; p++)
  36.     putchar(*p ^ 0xe5);
  37.  
  38.     return 0;
  39. }
  40.  
  41. It just uses a simple XOR, this will not stop a determined individual
  42. but for casually lookers there will be nothing to see.
  43.  
  44. Regards
  45.  
  46.    -A.
  47.  
  48. -- 
  49. | A.Champion                |
  50.